package com.ourteam.system.api;

import org.apache.commons.lang.ArrayUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.system.dao.SysUserRoleRelateDAOQueryBean;
import com.ourteam.system.domain.SystemUserRoleRelate;

public class SystemAccountRoleSearchModel extends AbstractSearchModel<SysUserRoleRelateDAOQueryBean> {

	private long sysAccountId;

	private String[] roleType;

	public String[] getRoleType() {
		return roleType;
	}

	public void setRoleType(String[] roleType) {
		this.roleType = roleType;
	}

	public long getSysAccountId() {
		return sysAccountId;
	}

	public void setSysAccountId(long sysAccountId) {
		this.sysAccountId = sysAccountId;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return SystemUserRoleRelate.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(SysUserRoleRelateDAOQueryBean queryBean) throws Exception {

		SysUserRoleRelateDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (ArrayUtils.isNotEmpty(this.roleType)) {
			criteria.andRoleTypeIn(roleType);
		}

		criteria.andUserIdEqualTo(sysAccountId);

	}

}
